#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os

try:
    # 执行CMD命令
    # f = os.popen('casperjs ../casperjs/each.js')
    f = os.popen('casperjs ../casperjs/baidulinks.js')
    # 获取结果，是一个file object
    text = f.read()
    # 判断字符串中包含子串
    if 'Unable to open file' in text:
        print "找不到文件啦！"
    else:
        # decode解决中文乱码
        print text.decode('UTF-8')
except:
    print '出错啦！'
finally:
    f.close()
